package com.example.service.usr.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.context.PageResult;
import com.example.entity.ProductCateDO;
import com.example.mapper.ProductCateMapper;
import com.example.service.usr.ProductCateService;
import com.example.vo.cate.ProdCateResp;
import com.example.vo.cate.UsrProdCatePageReq;
import org.springframework.stereotype.Service;

@Service
public class ProductCateServiceImpl extends ServiceImpl<ProductCateMapper, ProductCateDO>
        implements ProductCateService {
    @Override
    public PageResult<ProdCateResp> categoryPage(UsrProdCatePageReq req) {
        Page<ProductCateDO> page = new Page<>(req.getPage(), req.getSize());
        page = page(page, null);
        return PageResult.of(page.getTotal(), page.getCurrent(), page.getSize()
                , BeanUtil.copyToList(page.getRecords(), ProdCateResp.class));
    }
}
